﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.OleDb;
using WF_QLThuVien.Utilities;

namespace WF_QLThuVien.DataLayer
{
    public class CConnection
    {
        public static OleDbConnection dataConnection = null;

        public void Connection()
        {
            if (dataConnection == null)
            {
                try
                {
                    dataConnection = new OleDbConnection();
                    dataConnection.ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+CVariable.PATH;
                    dataConnection.Open();
                    if (dataConnection.State.ToString() != "Open")
                    {
                        throw new Exception("Lỗi Kết Nối!");
                    }
                }
                catch (System.Exception ex)
                {
                    throw new Exception("Lỗi Kết Nối");
                }
            }
        }

    }
}
